#ifndef THINK_THINK_CONSOLE_COMMAND_MAKE_H
#define THINK_THINK_CONSOLE_COMMAND_MAKE_H

static char* think_console_command_make =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2016 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: 刘志淳 <chun@engineer.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\console\\command;\n"
	"\n"
	"use think\\App;\n"
	"use think\\Config;\n"
	"use think\\console\\Command;\n"
	"use think\\console\\Input;\n"
	"use think\\console\\input\\Argument;\n"
	"use think\\console\\Output;\n"
	"\n"
	"abstract class Make extends Command\n"
	"{\n"
	"\n"
	"    protected $type;\n"
	"\n"
	"    abstract protected function getStub();\n"
	"\n"
	"    protected function configure()\n"
	"    {\n"
	"        $this->addArgument(\'name\', Argument::REQUIRED, \"The name of the class\");\n"
	"    }\n"
	"\n"
	"    protected function execute(Input $input, Output $output)\n"
	"    {\n"
	"\n"
	"        $name = trim($input->getArgument(\'name\'));\n"
	"\n"
	"        $classname = $this->getClassName($name);\n"
	"\n"
	"        $pathname = $this->getPathName($classname);\n"
	"\n"
	"        if (is_file($pathname)) {\n"
	"            $output->writeln(\'<error>\' . $this->type . \' already exists!</error>\');\n"
	"            return false;\n"
	"        }\n"
	"\n"
	"        if (!is_dir(dirname($pathname))) {\n"
	"            mkdir(strtolower(dirname($pathname)), 0755, true);\n"
	"        }\n"
	"\n"
	"        file_put_contents($pathname, $this->buildClass($classname));\n"
	"\n"
	"        $output->writeln(\'<info>\' . $this->type . \' created successfully.</info>\');\n"
	"\n"
	"    }\n"
	"\n"
	"    protected function buildClass($name)\n"
	"    {\n"
	"        $stub = file_get_contents($this->getStub());\n"
	"\n"
	"        $namespace = trim(implode(\'\\\\\', array_slice(explode(\'\\\\\', $name), 0, -1)), \'\\\\\');\n"
	"\n"
	"        $class = str_replace($namespace . \'\\\\\', \'\', $name);\n"
	"\n"
	"        return str_replace([\'{%className%}\', \'{%namespace%}\', \'{%app_namespace%}\'], [\n"
	"            $class,\n"
	"            $namespace,\n"
	"            App::$namespace,\n"
	"        ], $stub);\n"
	"\n"
	"    }\n"
	"\n"
	"    protected function getPathName($name)\n"
	"    {\n"
	"        $name = str_replace(App::$namespace . \'\\\\\', \'\', $name);\n"
	"\n"
	"        return APP_PATH . str_replace(\'\\\\\', \'/\', $name) . \'.php\';\n"
	"    }\n"
	"\n"
	"    protected function getClassName($name)\n"
	"    {\n"
	"        $appNamespace = App::$namespace;\n"
	"\n"
	"        if (strpos($name, $appNamespace . \'\\\\\') === 0) {\n"
	"            return $name;\n"
	"        }\n"
	"\n"
	"        if (Config::get(\'app_multi_module\')) {\n"
	"            if (strpos($name, \'/\')) {\n"
	"                list($module, $name) = explode(\'/\', $name, 2);\n"
	"            } else {\n"
	"                $module = \'common\';\n"
	"            }\n"
	"        } else {\n"
	"            $module = null;\n"
	"        }\n"
	"\n"
	"        if (strpos($name, \'/\') !== false) {\n"
	"            $name = str_replace(\'/\', \'\\\\\', $name);\n"
	"        }\n"
	"\n"
	"        return $this->getNamespace($appNamespace, $module) . \'\\\\\' . $name;\n"
	"    }\n"
	"\n"
	"    protected function getNamespace($appNamespace, $module)\n"
	"    {\n"
	"        return $module ? ($appNamespace . \'\\\\\' . $module) : $appNamespace;\n"
	"    }\n"
	"\n"
	"}\n"
	"\n"
;
#endif